﻿using System;
using System.Collections.Generic;
using System.Linq;
using JL.LiveAtEdu.Helpers;

namespace JL.LiveAtEdu.Portal
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButtonGo_OnClick(object sender, EventArgs e)
        {
            Bind.MyLiveUser = TxtUserName.Text;
            Bind.MyLivePassword = TxtPassword.Text;

            try
            {
                GridMain.DataSource = Messages.GetInboxReceivedMessagesList(int.Parse(TxtMaxNumber.Text), true);
                GridMain.DataBind();
            }
            catch (Exception ex)
            {   
                LitCount.Text = ex.Message;
            }
        }

        protected void LinkButtonCount_OnClick(object sender, EventArgs e)
        {
            Bind.MyLiveUser = TxtUserName.Text;
            Bind.MyLivePassword = TxtPassword.Text;

            try
            {
                LitCount.Text = String.Format("Inbox Read: {0} - Inbox Not Read: {1}", 
                    Messages.CountMessagesInbox(int.Parse(TxtMaxNumber.Text), true), 
                        Messages.CountMessagesInbox(int.Parse(TxtMaxNumber.Text), false));
            }
            catch (Exception ex)
            {
                LitCount.Text = ex.Message;
            }
        }
    }
}